package com.linkwings.projectsimple.http.action;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.linkwings.projectsimple.pojo.Book;
import com.linkwings.projectsimple.pojo.Bookcat;
import com.linkwings.projectsimple.pojo.SampleUser;
import com.linkwings.projectsimple.service.UserService;

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver ;

@Controller
@RequestMapping("/extuser")
public class ExtUserController {

	private UserService userService=null;

	   @RequestMapping(value="/list", method=RequestMethod.GET)
	   public  String list(HttpServletRequest request){
		  /*String serverInfo =  request.getSession().getServletContext().getServerInfo();
		  request.getSession().setAttribute("serverInfo", serverInfo);
		  */
		   	
		    Bookcat bc = userService.findBCByID(1);
		   
		    System.out.println("##############  "+bc.getName());
		    
		    Book book=userService.findBookByID(1);
		    System.out.println("##############[a]  "+book.getBookName());
		    System.out.println("##############[b]  "+book.getBookcat().getName());
		    System.out.println("##############[a]  "+book.getBookName());
		    System.out.println("##############[b]  "+book.getBookcat().getName());		    
		    Iterator<Book> it=bc.getBooks().iterator();
		    while(it.hasNext()){
		    	Book b = it.next();
		    	 System.out.println(">>>>>>>>>>>>  "+b.getBookName());
		    }
		    
		     return "/extuser/list";
	   }

	public void setUserService(UserService userService) {
		this.userService = userService;
	}



	   /*@RequestMapping(value="/showstr", method=RequestMethod.GET)
	   @ResponseBody
	   public  String showstr(HttpServletRequest request){*/
		  /*String serverInfo =  request.getSession().getServletContext().getServerInfo();
		  request.getSession().setAttribute("serverInfo", serverInfo);
		  */
		/*     return "hello ,my name is LK !";
	   }*/

}
